{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "_cell_guid": "71e0e53b-40f2-4fa8-8da7-e471d69507fa",
    "_execution_state": "busy",
    "_uuid": "aef8f5883c18e71345b887ba15202cabb1b02cf4"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "file read successfuly\n",
      "train and test sets created\n",
      "classifier created\n",
      "model evaluated\n",
      "0.9992275497879273\n"
     ]
    }
   ],
   "source": [
    "# This Python 3 environment comes with many helpful analytics libraries installed\n",
    "# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n",
    "# For example, here's several helpful packages to load in \n",
    "\n",
    "import numpy as np # linear algebra\n",
    "import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n",
    "from sklearn.neighbors import KNeighborsClassifier\n",
    "from sklearn.model_selection import train_test_split\n",
    "# Input data files are available in the \"../input/\" directory.\n",
    "# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n",
    "\n",
    "path = r\"D:\\datasets\\Credit Card Fraud Detection\\creditcard.csv\"\n",
    "\n",
    "data = pd.read_csv(path)\n",
    "print(\"file read successfuly\")\n",
    "\n",
    "X = data[[\"V1\",\"V2\",\"V3\",\"V4\",\"V5\",\"V6\",\"V7\",\"V8\",\"V9\",\"V10\",\"V11\",\"V12\",\"V13\",\"V14\",\"V15\",\"V16\",\"V17\",\"V18\",\"V19\",\"V20\",\"V21\",\"V22\",\"V23\",\"V24\",\"V25\",\"V26\",\"V27\",\"V28\",\"Amount\"]]\n",
    "y = data[\"Class\"]\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(X,y)\n",
    "print(\"train and test sets created\")\n",
    "\n",
    "knn = KNeighborsClassifier(n_neighbors = 5,n_jobs=16)\n",
    "knn.fit(X_train,y_train)\n",
    "print(\"classifier created\")\n",
    "score = knn.score(X_test,y_test)\n",
    "print(\"model evaluated\")\n",
    "print(score)\n",
    "\n",
    "# Any results you write to the current directory are saved as output."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}